<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>逛水果店</title>
  <script src="../vue.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    div {
      text-align: center;
    }

    table {
      margin: 0 auto
    }
  </style>
</head>

<body>
  <div id="app">
    <h1>欢迎光临水果店</h1>
    <table border="1" width="600" height="100">
      <caption>
        苹果{{price}}￥/斤，折扣/《{{zhekou}}折》
      </caption>
      <tbody>
        <tr>
          <td>
            <span>请输入你要购买的斤数</span>
            <input type="number" placeholder="请输入斤数" v-model.number="jinshu" />
          </td>
        </tr>
        <!-- <tr>
          <td>
            <button @click="buy">结账买单</button>
          </td>
        </tr> -->
      </tbody>
    </table>
    <p>结账单：总价:{{totalPrice}}元 省了:{{totalzhekouPrice}}元</p>
  </div>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        jinshu: '',
        price: 10,
        zhekou: 8
      },
      methods: {
        buy() { }
      },
      computed: {
        totalPrice() {
          return (this.jinshu * this.price * this.zhekou / 10).toFixed(2)
        },
        totalzhekouPrice() {
          return (this.jinshu * this.price).toFixed(2) - (this.jinshu * this.price * this.zhekou / 10).toFixed(2)
        }
      },
      watch: {

      }
    })
  </script>
</body>

</html>